package com.atguigu.spring6.autowired;

import com.atguigu.config.SpringConfig;
import com.atguigu.spring6.autowired.controller.UserController;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class TestUserController {

    @Test
    public void testAllAnnotation() {
        // (1)通过xml配置文件获取容器对象
        // ApplicationContext context =
        //         new ClassPathXmlApplicationContext("bean.xml");

        //  (2)通过注解配置类获取容器对象
        ApplicationContext context =
                new AnnotationConfigApplicationContext(SpringConfig.class);

        UserController controller = context.getBean(UserController.class);
        controller.add();
    }
}
